#读取存在flash中有效的指纹数量
import serial
import string
import binascii
import time
s=serial.Serial('/dev/ttyUSB0',115200)
valid=[0XEF,0X01,0XFF,0XFF,0XFF,0XFF,0X01,0X00,0X03,0X1D,0X00,0X21]
#最后的校验和要修改
StoreChar= [0XEF,0X01,0XFF,0XFF,0XFF,0XFF,0X01,0X00,0X06,0X06,0X01,0X00,0X07,0X00,0X15]
print('validTempleteNum:')
s.write(valid)
time.sleep(2)
number=s.inWaiting()
read= str(binascii.b2a_hex(s.read(number)))[2:-1]
print(read[19])
if read[19]=='0':
    print("OK")
else:
    print("NO")

num=read[22:24]
print("指纹数量"+num)
print(read)
#str_16 = binascii.b2a_hex(num.encode('utf-8'))  # 字符串转16进制
#print(str_16)
#print(type(str_16))
#print(type(StoreChar))
StoreChar[12]=num
print(StoreChar[12])


s.close()

